<!DOCTYPE html>
<html lang="zh-cn">
<html>
<head>
<meta charset="utf-8" />
<title>kcwebplus</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<meta name="MobileOptimized" content="320"/>
<link rel="stylesheet" href="${config.domain['kcwebstatic']}/element-ui/2.4.11/lib/theme-chalk/index.css"/>
<link rel="stylesheet" href="${config.domain['kcwebstatic']}/font/font-awesome-4.7.0/css/font-awesome.min.css"/>
<link rel="stylesheet" href="${config.domain['kcwebstatic']}/layer/3.1.1/theme/default/layer.css"/>
<link rel="stylesheet" href="/css/default.css"/>
<script src="${config.domain['kcwebstatic']}/other/polyfill.min.js"></script>
<script src="${config.domain['kcwebstatic']}/vue/2.6.10/vue.min.js"></script>
<script src="${config.domain['kcwebstatic']}/element-ui/2.4.11/lib/index.js"></script>
<script src="${config.domain['kcwebstatic']}/axios/0.18.0/axios.min.js"></script>
<script src="${config.domain['kcwebstatic']}/qs/6.5.2/qs.min.js"></script>
<script src="${config.domain['kcwebstatic']}/static/js/md5.min.js"></script>
<script src="${config.domain['kcwebstatic']}/jquery/2.2.4/jquery.min.js"></script>
<script src="${config.domain['kcwebstatic']}/layer/3.1.1/layer.js"></script>
<script src="/js/function.js"></script>
</head>
<style>
*{padding:0px;margin:0px}
.el-header, .el-footer {
    background-color: #B3C0D1;
    line-height: 60px;
    padding:0px;
    }
.kcw-side-scroll::-webkit-scrollbar{width:0px}
</style>
<body>
<div id="app">
        <div style="margin:10px auto;width:98%">
            <el-table :data="data.lists" :height="winheight-66">
                <el-table-column fixed prop="id" label="" width="10"></el-table-column>
                <el-table-column prop="title" label="任务名称" width="300">
                    <template slot-scope="scope">
                        <el-tooltip v-if="scope.row.describes" class="item" effect="dark" :content="scope.row.describes" placement="top-end">
                            <span>{{scope.row.title}}</span>
                        </el-tooltip>
                        <span v-else>{{scope.row.title}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="状态" width="200">
                    <template slot-scope="scope">
                        <span v-if="scope.row.code==1" type="text" size="mini">执行完成</span>
                        <span v-else-if="scope.row.code==2" type="text" size="mini"><i class="el-icon-loading"></i>等待排队中</span>
                        <span v-else-if="scope.row.code==3" type="text" size="mini"><i class="el-icon-loading"></i>进行中...</span>
                        <span v-else-if="scope.row.code==4" type="text" size="mini">执行完成</span>
                    </template>
                </el-table-column>
                <el-table-column prop="error" label=""></el-table-column>
                <!-- <el-table-column prop="msg" label="状态描述" width="100">
                    <template slot-scope="scope"><span v-if="scope.row.msg!='scope.row.msg'">{{scope.row.msg}}</span></template>
                </el-table-column> -->
                <el-table-column prop="addtime" label="添加时间" width="120">
                    <template slot-scope="scope">
                        <span v-html="time_date(scope.row.addtime)"></span>
                    </template>
                </el-table-column>
            </el-table>
            <div class="block" style="background:#FFF;margin-top:4px;height:36px;padding-top:4px">
                <el-pagination
                    @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="currentPage" :page-size="data.pagesize"
                    layout="total, sizes, prev, pager, next, jumper" :total="data.count">
                </el-pagination>
            </div>
        </div>
    

    
</div>
</body>
<script>
new Vue({
    el: '#app',
    data:{
        winheight:document.documentElement.clientHeight,
        winwidth:document.documentElement.clientWidth,
        data:{
            'count':0,
            'pagenow':1,
            'lists':[]
        },
        currentPage: 1,
        kw:null
    },
    mounted:function(){
        self=this
        window.onresize = function(){
            self.winheight=document.documentElement.clientHeight
            self.winwidth=document.documentElement.clientWidth
        }
        self.obtain()
    },
    methods: {
        taslstatus:function(item,index){
            self=this 
			setTimeout(function(){
                self.get("/intapp/index/task/taskstatus/"+item.taskid).then(function(res){
                    if(res.data.code==3){
                        self.taslstatus(item,index)
                    }else{
                        self.data.lists[index].code=res.data.code
                        self.data.lists[index].msg=res.data.msg
                        self.data.lists[index].error=res.data.error
                        self.data.lists[index].describes=res.data.describes
                    }
                })
            },5000);
        },
        obtain:function(){
			self=this
			self.get("/intapp/index/task/task",{pagenow:self.data.pagenow},'获取中...').then(function(res){
                self.data=res.data
                for(var i=0;i<res.data.lists.length;i++){
                    if(res.data.lists[i].code==3){
                        self.taslstatus(res.data.lists[i],i)
                    }
                }
			})
		},
		handleSizeChange:function(val) {
            self=this
			self.data.pagesize=val
			self.obtain()
		},
		handleCurrentChange:function(val) {
			self.data.pagenow=val
			self.obtain()
		}
    }
});
</script>
</html>